export default {
    name: "selectrichtext",
    isFunc: true,
    async bind(el, { value, oldValue }) {
        const { ids, list, id = "id", name = "name" } = value
        // 这里先判断新旧数据是否一样，如果一样就直接返回
        if (oldValue&&ids.length == oldValue.ids.length && ids.every((item, index) => item == oldValue.ids[index]) 
        && list.length == oldValue.list.length && (list.every((item, index) => item[id] == oldValue.list[index][id])||!list.length)) return
        await (el.__vue__||el._instance).$nextTick()
        setTimeout(()=>{
            const els = el.querySelectorAll('.el-tag .el-select__tags-text')
            ids.forEach((item,index)=>{
                const target = list.find(item2=>item2[id]===item)
                target&&(els[index].innerHTML = target[name])
            })
        },15)
       
    }
}